package de.daimler.my_sample;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

/**
 * A {@link FragmentPagerAdapter} that returns a fragment corresponding to one
 * of the primary sections of the app.
 */
public class SectionsPagerAdapter extends FragmentPagerAdapter {

	private MainActivity mainActivity;

	public SectionsPagerAdapter(FragmentManager fm, MainActivity mainActivity) {
		super(fm);
		this.mainActivity = mainActivity;
	}

	@Override
	public Fragment getItem(int i) {
		Fragment fragment = new DummySectionFragment();
		Bundle args = new Bundle();
		args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, i + 1);
		fragment.setArguments(args);
		return fragment;
	}

	@Override
	public int getCount() {
		return 4;
	}

	@Override
	public CharSequence getPageTitle(int position) {
		switch (position) {
		case 0:
			return mainActivity.getString(R.string.title_section1)
					.toUpperCase();
		case 1:
			return mainActivity.getString(R.string.title_section2)
					.toUpperCase();
		case 2:
			return mainActivity.getString(R.string.title_section3)
					.toUpperCase();
		case 3:
			return mainActivity.getString(R.string.title_section4)
					.toUpperCase();
		}
		return null;
	}
}